home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sr / info.lha / info-sr.1988 next >
Text File  |  1993-07-24  |  69KB  |  1,802 lines

  1. From info-sr-sender  Fri Mar 25 10:54:47 1988
  2. Received: by bocklin.arizona.edu; Fri, 25 Mar 88 10:54:52 MST
  3. Date: Fri, 25 Mar 88 10:54:47 MST
  4. From: "Gregg Townsend" <gmt>
  5. Message-Id: <8803251754.AA06773@bocklin.arizona.edu>
  6. To: info-sr@arizona.edu
  7. Subject: info-sr mailing list
  8. Errors-To: info-sr-errors
  9.  
  10. We have added your name to the info-sr mailing list;  welcome aboard!
  11.  
  12. Info-sr is a mailing list for discussing all aspects of the SR programming
  13. language and its implementation.  Your participation is encouraged;  the list
  14. is *not* restricted to SR "experts".
  15.  
  16. Messages sent to "info-sr@arizona.edu" are immediately redistributed to all
  17. members of the mailing list.
  18.  
  19. Administrative requests (e.g. changes of address, removal from list) should be
  20. sent to "info-sr-request@arizona.edu" and not to the general mailing list.
  21.  
  22. Other questions that are not of general interest can be sent directly to
  23. "sr-project@arizona".
  24.  
  25. If you should submit an item to info-sr and get back failure notifications from
  26. distant mailers, you can help us eliminate such problems by sending these
  27. notification messages to the request address above.  Our software tries to
  28. arrange for failure notifications to be sent to us, but this isn't foolproof.
  29.  
  30. From info-sr-sender  Mon May 16 05:26:24 1988
  31. Received: by bocklin.arizona.edu; Mon, 16 May 88 05:26:27 MST
  32. Message-Id: <8805161226.AA14456@megaron.arizona.edu>
  33. Date: 16 MAY 88 14:24-
  34. From: KIESEL%DBNINF5.BITNET@CUNYVM.CUNY.EDU
  35. To: INFO-SR@arizona.edu
  36. Subject: anything happend?
  37. Errors-To: info-sr-errors
  38.  
  39. Date: 16-MAY-1988 14:22:03.01
  40. From: Norbert Kiesel KIESEL AT DBNINF5
  41. To:   0::"info-sr@ARIZONA.EDU",KIESEL
  42. Subj: anything happend?
  43.                         Hi there,
  44. I Just wnt to know wether my subscription to this list has been successfull.
  45. It's now about three weeks ago and I haven't heard anything. Or is this
  46. just dead??
  47.  
  48.                 so long Norbert
  49.  
  50.  
  51. From info-sr-sender  Mon May 16 11:20:32 1988
  52. Received: by bocklin.arizona.edu; Mon, 16 May 88 11:20:35 MST
  53. Date: Mon, 16 May 88 11:20:22 MST
  54. From: "Gregg Townsend" <gmt>
  55. Message-Id: <8805161820.AA01862@megaron.arizona.edu>
  56. To: info-sr
  57. Subject: Re:  anything happend?
  58. Errors-To: info-sr-errors
  59.  
  60. Norbert Kiesel asked a question that several people are probably wondering
  61. about:  does the info-sr mailing list really work?
  62.  
  63. Well, yes, we think it does, but everybody's been VERY quiet.  This is
  64. probably because it's just starting up, but there should now be enough
  65. people to maintain a discussion.
  66.  
  67. I'll try and start something going by asking a provocative question:
  68. in your experiences with SR so far, what's the most surprising thing
  69. you've encountered?
  70.  
  71. (Remember, to join the discussion, just send your message to
  72.  info-sr@arizona.edu)
  73.  
  74.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  75.      +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  76.  
  77. From info-sr-sender  Mon May 16 19:15:33 1988
  78. Received: by bocklin.arizona.edu; Mon, 16 May 88 19:15:36 MST
  79. Date: 16 May 88 17:54 -0700
  80. From: Stella Atkins <stella%cmpt.sfu.cdn%ean.ubc.ca@RELAY.CS.NET>
  81. To: info-sr@arizona.edu
  82. In-Reply-To: <8805161820.AA01862@megaron.arizona.edu>
  83. Message-Id: <876*stella@cmpt.sfu.cdn>
  84. Subject: Re:  anything happend?
  85. Errors-To: info-sr-errors
  86.  
  87. At the risk of being facetious, I would say the most surprising thing about SR
  88. is that within 8 hours we had a working system which distributed over 4 SUN-3
  89. machines. Congratulations!
  90.  
  91.  
  92. From info-sr-sender  Tue May 17 02:14:14 1988
  93. Received: by bocklin.arizona.edu; Tue, 17 May 88 02:14:17 MST
  94. Date: 17 May 88  0:02 -0700
  95. From: Douglas Bailey <bailey%cmpt.sfu.cdn%ean.ubc.ca@RELAY.CS.NET>
  96. To: info-sr@arizona.edu
  97. Message-Id: <118*bailey@cmpt.sfu.cdn>
  98. Subject: surprises
  99. Errors-To: info-sr-errors
  100.  
  101. Allright -- the thing I found to be most surprising is the extremely high
  102. cost of communication between different vms (either on the same or different
  103. physical machines).  I ran a simple test, and the *best* results I got
  104. indicated that a vm to vm send required about 100ms.  Is this typical, or
  105. just a result of something strange in our network?
  106.  
  107. Doug Bailey / Simon Fraser University / Burnaby, B.C. Canada
  108.  
  109.  
  110. From info-sr-sender  Tue May 17 06:27:22 1988
  111. Received: by bocklin.arizona.edu; Tue, 17 May 88 06:27:25 MST
  112. Message-Id: <8805171325.AA01371@megaron.arizona.edu>
  113. Date: 17 MAY 88 14:50-
  114. From: KIESEL%DBNINF5.BITNET@CUNYVM.CUNY.EDU
  115. To: INFO-SR@arizona.edu
  116. Subject: Some remarks on SR
  117. Errors-To: info-sr-errors
  118.  
  119. Date: 17-MAY-1988 14:48:33.73
  120. From: Norbert Kiesel KIESEL AT DBNINF5
  121. To:   0::"info-sr@arizona.edu",KIESEL
  122. Subj: Some remarks on SR
  123.                 Hello SR friends,
  124. I'm the one who kicked the first stone (into info-sr :-).  Up to now, I
  125. haven't got the SR compiler, as I'm not on ARPANET and have to wait
  126. for my tape.  But at all, I've some remarks on SR resulting from
  127. reading the TR 86-6c "An Overview of the SR Language and
  128. Implementation":
  129.  
  130.  
  131.     1)  Why is the declaration of the resource parameters not a part of
  132.         the specification?  This is much more in the sense of writing
  133.         modular programs as a user of a resource only needs to know
  134.         the specification and not the body for using it, i.e the
  135.         internals would be hidden.
  136.  
  137.     2)  Was it really a good idea to add the parameter kind "ref" for
  138.         operations called on the same vm?  This breaks transparency
  139.         and must (?) be controlled for every invocation.
  140.  
  141. There is a typo in the "Dining Philosophers" program: Instances of
  142. "Servant" resources are created with a parameter which isn't specified
  143. in the body of "Servant".
  144.  
  145. Last not least I have a question to the Saguaro example (in the same
  146. report): Is there a special resaon for counting the number of
  147. processes accessing the same file in "DirectoryMgr" and not in
  148. "FileServer"?
  149.  
  150.  
  151.                 so long Norbert
  152.  
  153. P.S.: I'm interested in porting SR to XENIX 3.3 running on Intel
  154. 310/12 (we've some of them connected via Ethernet). Does anyone has
  155. got the same idea? NK
  156.  
  157. From info-sr-sender  Tue May 17 08:36:53 1988
  158. Received: by bocklin.arizona.edu; Tue, 17 May 88 08:36:56 MST
  159. Date: Tue, 17 May 88 08:36:50 MST
  160. From: "Greg Andrews" <greg>
  161. Message-Id: <8805171536.AA20404@paloverde>
  162. To: info-sr
  163. Subject: responses
  164. Errors-To: info-sr-errors
  165.  
  166. It's nice to see some interest -- and good questions.
  167.  
  168. Credit for the distribution goes to Gregg Townsend
  169. and Ron Olsson.  I had the sense to stay out of their way.
  170.  
  171. The inter-vm time is high, due to Unix overhead.
  172. There is also extra overhead on the first use of a new vm
  173. because of the way vm's are managed.
  174. Before too long we should have a native implementation
  175. on top of a kernel (the x-kernel) being developed
  176. here by Larry Peterson and Norm Hutchinson.  Times
  177. should then be quite reasonable, but the distribution
  178. will be less usable since it won't have Unix.  If Mach
  179. eventually supplants Unix, we should be able to get
  180. a much more efficient implementation.
  181.  
  182. The declaration of resource parameters *is* part of the
  183. spec in the current version of SR.  TR 86-6c, which is
  184. the TOPLAS paper that appeared in January, is not quite
  185. accurate.  We realized the problem shortly after the last
  186. revision to that paper and changed the implementation.
  187. The paper is otherwise pretty accurate though.
  188.  
  189. Yes, there are dangers associated with using ref parameters --
  190. and pointers too for that matter.  However, we felt that
  191. we should not force inefficient solutions on some problems
  192. just for the sake of purity and transparency.  There are
  193. already a hundred ways the programmer can hang him/herself.
  194.  
  195. There is indeed a typo in the Dining Philosophers program.
  196. Servant resources should not be created with parameter i.
  197.  
  198. In the Saguaro example, Directory Managers coordinate File
  199. Server creation/destruction.  Thus they need to know how
  200. many clients are using a file.  If that number were in
  201. the File Server, there could be a race condition if the
  202. last client known to the server closed the file at about
  203. the same time a new client opened it.  In particular, the
  204. File Server could destroy itself at the same time another
  205. client tried to start using it.  The problem is avoided
  206. by the standard technique of using a centralized allocator,
  207. in this case the Directory Manager.
  208.  
  209. -- Greg
  210.  
  211. From info-sr-sender  Tue May 17 10:34:12 1988
  212. Received: by bocklin.arizona.edu; Tue, 17 May 88 10:34:15 MST
  213. Date: Tue, 17 May 88 10:34:10 MST
  214. From: "Gregg Townsend" <gmt>
  215. Message-Id: <8805171734.AA13050@megaron.arizona.edu>
  216. To: info-sr
  217. Subject: communication rates
  218. Errors-To: info-sr-errors
  219.  
  220. It turns out that the number of messages passing between virtual machines
  221. is limited by the granularity of SR's internal clock. This is the
  222. CLOCK_INTERVAL parameter in limits.h.
  223.  
  224. You can experiment with different values by setting an environment
  225. variable SRCLOCK to a granularity in milliseconds, with the caveat
  226. that your environment variables don't affect remote virtual machines.
  227.  
  228. The default clock interval is 100 milliseconds.  I just did some
  229. experimentation here and found that by setting it to 10 I could get
  230. 200 messages (100 round trips) per second on a vax, or 5ms/message.
  231. Values less than 10 didn't help any.
  232.  
  233. I'm going to change the default for future releases;  you might wish to do
  234. the same with your versions.  CLOCK_INTERVAL is only referenced in
  235. rts/process.c, so only the runtime system will require a rebuild.
  236.  
  237.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  238.      +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  239.  
  240. From @CUNYVM.CUNY.EDU:KIESEL@DBNINF5.BITNET  Thu May 19 09:00:39 1988
  241. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 19 May 88 09:00:39 MST
  242. Message-Id: <8805191559.AA26230@megaron.arizona.edu>
  243. Received: from [128.228.1.2] by megaron.arizona.edu; Thu, 19 May 88 08:59:15 MST
  244. Received: from DBNINF5.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 5260; Thu, 19 May 88 11:56:01 EDT
  245. Date: 19 MAY 88 17:12-
  246. From: KIESEL%DBNINF5.BITNET@CUNYVM.CUNY.EDU
  247. To: INFO-SR@arizona.edu
  248. Subject: ?-operator still existing ?
  249.  
  250. Date: 19-MAY-1988 17:09:40.22
  251. From: Norbert Kiesel KIESEL AT DBNINF5
  252. To:   SR,KIESEL
  253. Subj: ?-operator still existing ?
  254.                         Hello,
  255. I've just a liite question:
  256.  
  257. Does the ?-operator still exists in SR? If it exists, what's its syntax
  258. and semantics? (I haven't yet the actual reference manual).
  259.  
  260.                 so long Norbert
  261.  
  262. From greg  Thu May 19 09:08:04 1988
  263. Received: from paloverde.arizona.edu by bocklin.arizona.edu; Thu, 19 May 88 09:08:04 MST
  264. Date: Thu, 19 May 88 09:07:59 MST
  265. From: "Greg Andrews" <greg>
  266. Message-Id: <8805191607.AA04264@paloverde>
  267. Received: by paloverde; Thu, 19 May 88 09:07:59 MST
  268. In-Reply-To: <8805191559.AA26230@megaron.arizona.edu>
  269. To: INFO-SR@arizona.edu, KIESEL%DBNINF5.BITNET@CUNYVM.CUNY.EDU
  270. Subject: Re:  ?-operator still existing ?
  271.  
  272. Yes, it exists.  Its syntax is
  273.  
  274.     ?operation
  275.  
  276. where operation is the identity of the operation.
  277.  
  278. -- Greg
  279.  
  280. From @CORNELLC.CCS.CORNELL.EDU:KIESEL@DBNINF5.BITNET  Mon May 30 03:54:26 1988
  281. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 30 May 88 03:54:26 MST
  282. Message-Id: <8805301054.AA17897@megaron.arizona.edu>
  283. Received: from [128.253.7.20] by megaron.arizona.edu; Mon, 30 May 88 03:54:09 MST
  284. Received: from DBNINF5.BITNET by CORNELLC.CCS.CORNELL.EDU ; Mon, 30 May 88 06:28:52 EDT
  285. Date: 30 MAY 88 12:12-
  286. From: KIESEL%DBNINF5.BITNET@CORNELLC.CCS.CORNELL.EDU
  287. To: INFO-SR@arizona.edu
  288. Subject: primes program
  289.  
  290. Date: 30-MAY-1988 11:33:25.11
  291. From: Norbert Kiesel KIESEL AT DBNINF5
  292. To:   SR,KIESEL
  293. Subj: primes program
  294.                         Hello SR-friends,
  295. following is a (nearly guaranteed faulty :-) little SR program to
  296. calculate some primes. The basic idea is: create some processes,
  297. distribute them over all machines (i.e. encapsulate them resources),
  298. and send them a prime number candidate. Each of the processes builds
  299. up a (disjunct) list of primes against which the new candidate is tested.
  300. If all processes agree about the candidate to be prime, its given to one
  301. of the processes enlarging his prime number list.
  302.  
  303. The program is not intended to be the fastest prime number searcher, it
  304. should just give an impression how much improvement one can get by writing
  305. distributed solutions for problems. The right test candidate for this
  306. program is the program itself -- with just one local test process.
  307.  
  308. I've neither the SR compiler nor the current SR language reference manual,
  309. so I can't test or verify my solution. However, if someone is interested
  310. in this problem, (s)he can either modify&try my solution or write another
  311. one. Any responses are wellcome!!!
  312.  
  313.                 so long Norbert
  314.  
  315. =-=-=-=-=-=-=-=-=- snipp, snipp, snipp -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  316.  
  317. resource main(max:int,num:int)
  318. body main
  319.       import pt
  320.       var ptc[1:max]:cap pt
  321.  
  322. initial
  323.       fa i := 1 to num ->
  324.             ptc[i] := create pt(max)    # on every possible machine
  325.       af
  326. end
  327.  
  328. final
  329.       fa i := 1 to num
  330.             destroy ptc[i]
  331.       af
  332. end
  333.  
  334. process loop
  335.       var is_prim_for_me:bool
  336.       var turn:int := 1
  337.       var vote:int
  338.  
  339.       fa i := 2 to max st i=2 | i=3 | i=5 | (i>6 & ((i-1)%6=0 | (i-5)%6=0)) ->
  340.             vote := 0
  341.             co (j := 1 to num) ->
  342.                   ptc[j].guess(i,is_prim_for_me) ->
  343.                         if is_prim_for_me ->
  344.                               vote++
  345.                               if vote=num ->
  346.                                     ptc[turn].take(i)
  347.                                     turn := (turn%num) + 1
  348.                                     write(i," ")
  349.                                     exit
  350.                               [] else ->
  351.                                     next
  352.                               fi
  353.                         [] else ->
  354.                               exit
  355.                         fi
  356.             oc
  357.       af
  358. end
  359.  
  360.  
  361.  
  362. resource pt(max:int)
  363.  
  364.       op guess(val n:int; res pfm:bool) {call}
  365.       op take(val n:int) {call}
  366.  
  367. body pt
  368.  
  369. process test
  370.       var primes[1:max]:int
  371.       var last:int := 0
  372.  
  373.       do true ->
  374.             in guess(n,pfm) ->
  375.                   fa i := 1 to last ->
  376.                         if (n%primes[i] = 0 or ?guess > 0) ->
  377.                               pfm := false
  378.                               return
  379.                         fi
  380.                   af
  381.                   pfm := true
  382.             [] take(n) ->
  383.                   last++
  384.                   primes[last] := n
  385.             ni
  386.       od
  387. end
  388.  
  389. =-=-=-=-=-=-=-=-=-=- snipp, snipp, snipp -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  390.  
  391. P.S.: I've called for a SR compiler using the order form. As my university
  392. isn't very happy about sending money without a bill, I've called for
  393. a purchase-order processing. Some days ago I've got my order back with
  394. a letter saying that there was no payment enclosed and so my order has not
  395. been processed. So what's about purchase-order processing? Have I misunderstood
  396. anything? NK
  397.  
  398. From gmt  Thu Jun 23 16:41:41 1988
  399. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 23 Jun 88 16:41:41 MST
  400. Date: Thu, 23 Jun 88 16:41:39 MST
  401. From: "Gregg Townsend" <gmt>
  402. Message-Id: <8806232341.AA16943@megaron.arizona.edu>
  403. Received: by megaron.arizona.edu; Thu, 23 Jun 88 16:41:39 MST
  404. To: info-sr
  405. Subject: troff formatter for SR
  406.  
  407. Several people have worked on vgrind definitions for SR.  I've incorporated
  408. those along with some ideas of my own in the program below.  It's a shell
  409. script that calls vgrind, plus a man page.  This has been tested on a Vax
  410. (4.3BSD) and a Sun (SunOS 3.4).
  411.  
  412.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  413.      +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  414.  
  415.  
  416. # To unbundle, sh this file
  417. echo unbundling srgrind.1 1>&2
  418. cat >srgrind.1 <<'AlBeRtEiNsTeIn'
  419. .TH SRGRIND 1 "22 June 1988" "University of Arizona"
  420. .SH NAME
  421. srgrind \- format SR program for troff
  422. .SH SYNOPSIS
  423. \fBsrgrind [\-f] [\-n] [\-w] [\-x] [\-d \fIdefs\fP] \
  424. [\-h \fIheader\fP] [\-s \fIsize\fP] [\fRfile ...\fP]
  425. .br
  426. .SH DESCRIPTION
  427. .LP
  428. .I Srgrind
  429. formats an SR program for typesetting by
  430. .IR troff (1).
  431. .I Srgind
  432. is a front end to
  433. .IR vgrind (1).
  434. .LP
  435. Input is read from the named files, or from standard input if none are given.
  436. The
  437. .I troff
  438. directives are written to standard output.
  439. .LP
  440. .I Srgrind
  441. accepts the following options:
  442. .TP 11
  443. .BI \-d " defs"
  444. Use an alternate
  445. .IR vgrindefs (5)
  446. file instead of the default one inside
  447. .I srgrind.
  448. .TP
  449. .BI \-f
  450. Run in filter mode. 
  451. In this mode,
  452. .I srgrind
  453. passes most input untouched, processing only those lines
  454. delimited by
  455. .B .vS
  456. and
  457. .B .vE
  458. macro calls.
  459. .TP
  460. .BI \-h " header"
  461. Place a header at the top of the page.
  462. .TP
  463. .BI \-n
  464. Don't embolden keywords.
  465. .TP
  466. .BI \-s " size"
  467. Set the pointsize for typesetting.
  468. .TP
  469. .BI \-w
  470. Consider tabs to be spaced every four columns instead of every eight
  471. (Sun only).
  472. .TP
  473. .BI \-x
  474. Pass
  475. .B \-x
  476. to
  477. .I vgrind
  478. for index processing.
  479. .SH SEE ALSO
  480. .LP
  481. sr(1), troff(1), vgrind(1), vgrindefs(5), srtex(1)
  482. .SH CAVEATS
  483. .LP
  484. .I Srgrind
  485. is limited by the capabilities of
  486. .IR vgrind .
  487. For example, comments of the form /*...*/ do not nest.
  488. .LP
  489. .I Vgrind
  490. macros can conflict with others when using filter mode.
  491. AlBeRtEiNsTeIn
  492. echo unbundling srgrind 1>&2
  493. cat >srgrind <<'AlBeRtEiNsTeIn'
  494. #!/bin/sh
  495. #
  496. #   format an SR file for troff using vgrind's back end
  497.  
  498. #   This script calls the undocumented "vfontedpr" directly because
  499. #   /usr/ucb/vgrind is badly (& differently) broken on both Vax (4.3 Mt Xinu)
  500. #   and Sun (3.5); for example, try a  simple "TROFF=cat vgrind foo.c".
  501.  
  502. #   Note that we allow "-s 12" and "-dfile" as well as the "-s12" and "-d file"
  503. #   forms vgrind insists on; but we still don't allow "-fn" for "-f -n".
  504.  
  505. #   vgrindefs below are based on efforts of Roger Hayes, Doug Cook, Ron Olsson.
  506.  
  507. USAGE="[-f] [-n] [-w] [-x] [-s size] [-d defs] [-h header] [file...]"
  508.  
  509. VFPATH="/usr/lib/vfontedpr"
  510. VGMACS="/usr/lib/tmac/tmac.vgrind"
  511.  
  512. TEMP=/tmp/srg.$$
  513.  
  514. # copy default vgrindefs(5) to a temp file
  515. #
  516. # strings don't really end at EOL, but we'll say they do to help
  517. # resynchronize things if vgrind gets confused
  518.  
  519. trap "rm -f $TEMP" 0 1 2 15
  520. cat >$TEMP <<"==END=="
  521. sr|SR:\
  522.     :pb=\d(((proc(ess?))|resource|global)\d\p(\d|\())|(body\d\p\d?(/|#|$)):\
  523.     :bb=\d(if|fa|do|co|in|initial|final)\d:\
  524.     :be=\d(fi|af|od|oc|ni|end)\d:\
  525.     :cb=#:ce=$:\
  526.     :ab=/*:ae=*/:\
  527.     :sb=":se=(\e"|$):\
  528.     :lb=':le=(\e'|$):\
  529.     :kw=af and any body bool by call cap char co const create destroy do \
  530.     downto else end enum EOF exit extend external fa false fi file final \
  531.     global if import in initial int new next ni noop not null oc od on op \
  532.     optype or proc process ptr rec receive ref reply res resource return \
  533.     rn returns send separate skip st stop string to true type val var xor:
  534. ==END==
  535.  
  536.  
  537. # process command options
  538.  
  539. DEFS=$TEMP
  540. OPTIONS=
  541. for i
  542. do
  543.     case $i in
  544.     -[fnx])
  545.         OPTIONS="$OPTIONS $i"
  546.         shift;;
  547.     -w)
  548.         OPTIONS="$OPTIONS -t"
  549.         shift;;
  550.     -s)
  551.         shift
  552.         test $# '=' 0 && echo "$0: $i requires a value" 1>&2 && exit 1
  553.         OPTIONS="$OPTIONS -s$1"
  554.         shift;;
  555.     -s?*)
  556.         OPTIONS="$OPTIONS $i"
  557.         shift;;
  558.     -d)
  559.         shift
  560.         test $# '=' 0 && echo "$0: $i requires a value" 1>&2 && exit 1
  561.         DEFS="$1"
  562.         shift;;
  563.     -d?*)
  564.         val=`echo $i | sed 's/..//'`
  565.         OPTIONS="$OPTIONS -d $val"
  566.         shift;;
  567.     -h)
  568.         shift
  569.         test $# '=' 0 && echo "$0: $i requires a value" 1>&2 && exit 1
  570.         OPTIONS="$OPTIONS -h '$1'"
  571.         shift;;
  572.     -h?*)
  573.         val=`echo "$i" | sed 's/..//'`
  574.         OPTIONS="$OPTIONS -h '$val'"
  575.         shift;;
  576.     --)
  577.         shift
  578.         break;;
  579.  
  580.     -*)
  581.         echo "usage: $0 $USAGE" 1>&2
  582.         exit 1;;
  583.     *)
  584.         break;;
  585.     esac
  586.     done
  587.  
  588.  
  589. # turn a null file list into "-" for the back end
  590.  
  591. case $# in
  592.     0)    FILES="-";  break;;
  593.     *)    FILES="$@"; break;;
  594.     esac
  595.  
  596.  
  597. # insert a call for the macros, and then call the back end
  598. # "eval" is used to get quoting right (e.g. "srgrind -h 'tricky header')
  599.  
  600. echo ".so $VGMACS"
  601. eval $VFPATH -lsr -d $DEFS $OPTIONS $FILES
  602. exit
  603. AlBeRtEiNsTeIn
  604. chmod +x srgrind
  605.  
  606. From cook@iris.ucdavis.edu  Thu Jun 23 17:02:49 1988
  607. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 23 Jun 88 17:02:49 MST
  608. Received: from clover.ucdavis.edu by megaron.arizona.edu; Thu, 23 Jun 88 17:02:37 MST
  609. Received: from iris.ucdavis.edu by clover.ucdavis.edu (5.59/4.7)
  610.     id AA06075; Thu, 23 Jun 88 16:52:36 PDT
  611. Received: by iris.ucdavis.edu (5.51/3.14)
  612.     id AA11612; Thu, 23 Jun 88 16:59:55 PDT
  613. Date: Thu, 23 Jun 88 16:59:55 PDT
  614. From: cook@iris.ucdavis.edu (Doug Cook)
  615. Message-Id: <8806232359.AA11612@iris.ucdavis.edu>
  616. To: info-sr@arizona.edu
  617. Subject: X windows interface for SR
  618. Cc: cook@iris.ucdavis.edu, olsson@ivy.ucdavis.edu
  619.  
  620.  
  621.     I have been working on a (hopefully!) easy-to use, high-level X windows 
  622. interface to the SR language. Essentially what I hope to do is to represent each
  623. SR proc/process or resource as an X-window with its own I/O, scrollbar, buttons,
  624. etc. I'd also like the configuration of a group of windows to be user-defined.
  625.     For example, a hypercube simulator written in SR could, using this 
  626. interface, represent each processor in the network as a window, and the windows 
  627. could be arranged in a hypercube. This would require very little additional
  628. SR code. Additionally, this interface could form part of an SR debugging tool,
  629. since it allows each process to be separately monitored.
  630.     At the moment, I've got a somewhat brain-damaged prototype running
  631. under X 11 release 2, and I'm working on a more flexible version. Before I go
  632. and put a lot of additional work into this, I'd like to know two things:
  633.     1) Is anyone out there working on anything similar?
  634.     2) What would people like to see implemented in such an interface? 
  635.  
  636.         -Doug
  637.  
  638. From AJCD@ECSVAX.ED.AC.UK  Mon Jul 11 12:26:04 1988
  639. Received: from megaron.arizona.edu by bocklin.arizona.edu; Mon, 11 Jul 88 12:26:04 MST
  640. Received: from rvax.ccit.arizona.edu by megaron.arizona.edu (5.59/MRM1.4) via SMTP
  641.     id AA23478; Mon, 11 Jul 88 12:26:01 MST
  642. Received: from BITNET-GATEWAY by rvax.ccit.arizona.edu; Mon, 11 Jul 88 12:19 MST
  643. Received: from RL.IB by UKACRL.BITNET (Mailer X1.25) with BSMTP id 7062; Mon,
  644.  11 Jul 88 12:21:15 BST
  645. Date: 11 Jul 88 12:25:29 BST
  646. From: AJCD@ECSVAX.ED.AC.UK
  647. Subject: RTS bind problem on Suns
  648. To: info-sr@arizona.edu
  649. Via:        UK.AC.ED.ECSVAX; 11 JUL 88 12:21:04 BST
  650. Message-Id: <"11-JUL-1988 12:25:30">
  651.  
  652.    I have just received the SR tape, and installed it on some of our Sun
  653. workstations. When I tried the examples/remote test in the installation
  654. document I got an error -
  655.  
  656.    islay% a.out skye
  657.    trying locally:    0.  pid=2398    host=islay
  658.    trying skye:    1.  pid=3707    host=skye
  659.  
  660.    islay% a.out arran
  661.    trying locally:    0.  pid=2406    host=islay
  662.    trying arran:    [vm 3] RTS abort: bind: Can't assign requested address
  663.    can't create vm on arran
  664.  
  665.    This error only occurs when trying to bind to a virtual machine on
  666. the diskless nodes; between the disk servers it works fine. Has anyone
  667. come across this problem, and how can it be sorted? I think we are running
  668. SunOS 3.2 on these machines.
  669.                                  Thanks,
  670.                                        Angus
  671.  
  672. --
  673. Angus Duggan, Department of Computer Science, University of Edinburgh,
  674. James Clerk Maxwell Building, The King's Buildings, Mayfield Road,
  675. Edinburgh, EH9 3JZ, Scotland, U.K.
  676. JANET:  ajcd@uk.ac.ed.ecsvax  ARPA: ajcd%ed.ecsvax@nss.cs.ucl.ac.uk
  677. USENET: ajcd@ecsvax.ed.ac.uk  UUCP: ...!mcvax!ukc!ed.ecsvax!ajcd
  678. BITNET: ukacrl.earn!ed.ecsvax!ajcd or ajcd%ed.ecsvax@uk.ac
  679.  
  680. From @RELAY.CS.NET:bailey%cmpt.sfu.cdn@ean.ubc.ca  Tue Jul 12 08:42:43 1988
  681. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 12 Jul 88 08:42:43 MST
  682. Received: from RELAY.CS.NET by megaron.arizona.edu (5.59/MRM1.4) via SMTP
  683.     id AA21298; Tue, 12 Jul 88 08:42:30 MST
  684. Received: from relay2.cs.net by RELAY.CS.NET id ac13042; 12 Jul 88 10:54 EDT
  685. Received: from ubc by RELAY.CS.NET id ac17405; 12 Jul 88 10:45 EDT
  686. Received: by ean.ubc.ca id AA00425; Mon, 11 Jul 88 22:35:17 pdt
  687. Date: 11 Jul 88 22:33 -0700
  688. From: Douglas Bailey <bailey%cmpt.sfu.cdn%ean.ubc.ca@RELAY.CS.NET>
  689. To: info-sr@arizona.edu
  690. Message-Id: <166*bailey@cmpt.sfu.cdn>
  691. Subject: Bind error
  692.  
  693. I did have similar problems.  I was running distributed programs
  694. on a LAN with several Sun-3's (BSD Unix 3.2).  Particular Sun-3's
  695. could not be used because of the problem you described.  This was
  696. not a problem with SR, however, but rather with Unix.  My supervisor
  697. wrote a C program that had the same problem (hers was one of the
  698. machines which could not be used in a distributed program).  Our
  699. system operator messed around for a while and eventually fixed it,
  700. but I believe he said something to the effect that he did not know
  701. what it was that he did to fix it.  Stella: what did Honman say,
  702. precisely?
  703.  
  704. Doug Bailey
  705.  
  706.  
  707. From olsson@ivy.ucdavis.edu  Tue Jul 12 12:57:09 1988
  708. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 12 Jul 88 12:57:09 MST
  709. Received: from clover.ucdavis.edu by megaron.arizona.edu (5.59/MRM1.4) via SMTP
  710.     id AA09415; Tue, 12 Jul 88 12:57:01 MST
  711. Received: from ivy.ucdavis.edu by clover.ucdavis.edu (5.59/4.7)
  712.     id AA29166; Tue, 12 Jul 88 12:45:27 PDT
  713. Received: by ivy.ucdavis.edu (3.2/3.14)
  714.     id AA18653; Tue, 12 Jul 88 12:54:25 PDT
  715. Date: Tue, 12 Jul 88 12:54:25 PDT
  716. From: olsson@ivy.ucdavis.edu (Ron Olsson)
  717. Message-Id: <8807121954.AA18653@ivy.ucdavis.edu>
  718. To: info-sr@arizona.edu
  719. In-Reply-To: AJCD@ECSVAX.ED.AC.UK's message of 11 Jul 88 12:25:29 BST <"11-JUL-1988 12:25:30">
  720. Subject: RTS bind problem on Suns
  721.  
  722.    Date: 11 Jul 88 12:25:29 BST
  723.    From: AJCD@ECSVAX.ED.AC.UK
  724.  
  725.       I have just received the SR tape, and installed it on some of our Sun
  726.    workstations. When I tried the examples/remote test in the installation
  727.    document I got an error -
  728.    ...
  729.       This error only occurs when trying to bind to a virtual machine on
  730.    the diskless nodes; between the disk servers it works fine. Has anyone
  731.    come across this problem, and how can it be sorted? I think we are running
  732.    SunOS 3.2 on these machines.
  733.  
  734. Sorry to say that Gregg Townsend -- who would most likely be able to
  735. help you with this problem -- is on vacation for a few weeks.  Doug
  736. Bailey's message suggests that the problem is UNIX's not SR's; I hope
  737. he can provide the details to resolve this problem.
  738.  
  739.  
  740. From @RELAY.CS.NET:stella%cmpt.sfu.cdn@ean.ubc.ca  Tue Jul 12 21:05:48 1988
  741. Received: from megaron.arizona.edu by bocklin.arizona.edu; Tue, 12 Jul 88 21:05:48 MST
  742. Received: from RELAY.CS.NET by megaron.arizona.edu (5.59/MRM1.4) via SMTP
  743.     id AA13353; Tue, 12 Jul 88 21:05:40 MST
  744. Received: from relay2.cs.net by RELAY.CS.NET id ab22619; 12 Jul 88 23:44 EDT
  745. Received: from ubc by RELAY.CS.NET id af22248; 12 Jul 88 23:36 EDT
  746. Received: by ean.ubc.ca id AA00412; Tue, 12 Jul 88 18:00:11 pdt
  747. Date: 12 Jul 88 17:56 -0700
  748. From: Stella Atkins <stella%cmpt.sfu.cdn%ean.ubc.ca@RELAY.CS.NET>
  749. To: info-sr@arizona.edu
  750. Message-Id: <1070*stella@cmpt.sfu.cdn>
  751. Subject: Bind error -- solution!!
  752.  
  753. I amiled a direct reply to angus, but thought the group might be interested too.
  754. Here is the magic solution.
  755. Stella Atkins
  756. stella@cmpt.sfu.cdn
  757.  
  758.  
  759. ==================
  760. The problem concerns the binding between the network address to
  761.  the link address. The manual page on ifconfig(8) indicates that
  762. the binding is turned on by default. Somehow something has turned off the
  763. binding. 
  764.  
  765. Solution: execute the following command as root:
  766.  
  767.     /etc/ifconfig ethernet-interface hostname arp
  768.  
  769. eg if you have a SUN-3/50 and the hostname is star, then you should execute:
  770.     /etc/ifconfig le0 star arp
  771.  
  772. Magic!!
  773. It took me 2 weeks to discover this. I hope you can use this info to fix
  774. your problem.
  775.  
  776.  
  777.  
  778. From @RELAY.CS.NET:bawtree%cmpt.sfu.cdn@ean.ubc.ca  Thu Jul 21 16:41:03 1988
  779. Received: from megaron.arizona.edu by bocklin.arizona.edu; Thu, 21 Jul 88 16:41:03 MST
  780. Received: from RELAY.CS.NET by megaron.arizona.edu (5.59-1.5) via SMTP
  781.     id AA15075; Thu, 21 Jul 88 16:39:25 MST
  782. Received: from relay2.cs.net by RELAY.CS.NET id aa28761; 21 Jul 88 18:00 EDT
  783. Received: from ubc by RELAY.CS.NET id ac03580; 21 Jul 88 17:40 EDT
  784. Received: by ean.ubc.ca id AA11705; Thu, 21 Jul 88 13:47:44 pdt
  785. Date: 21 Jul 88 13:36 -0700
  786. From: Hugh Bawtree <bawtree%cmpt.sfu.cdn%ean.ubc.ca@RELAY.CS.NET>
  787. To: info-sr@arizona.edu
  788. Mmdf-Warning:  Parse error in original version of preceding line at RELAY.CS.NET
  789. Message-Id: <4*bawtree@cmpt.sfu.cdn>
  790. Subject: SR on non-UNIX opsys
  791.  
  792. I just joined the info-sr group, so I am quite ignorant of the current
  793. development of SR.  I am hoping to implement SR on the V-system
  794. for my M Sc thesis at Simon Fraser University, Burnaby, BC, Canada.
  795. Some of you must know my supervisor: Stella Atkins.
  796.  
  797. Is anyone else implementing SR on non-UNIX systems?  If so, what
  798. kind of problems are you running into?  I hope a V-system
  799. implementation can use a large portion of the code written for
  800. the UNIX implementation of SR but I have found the following
  801. changes must be made:
  802.  
  803.     a) Replace the socket module in the RTS with the V-system
  804.     communication primitives.
  805.  
  806.     b) Replace the UNIX system calls scattered throughout the
  807.     code with the appropriate V system calls.  In many cases,
  808.     this by itself would not be difficult.  However, I would
  809.     like to do it in a consistent manner.  For instance, I
  810.     could replace all the UNIX system calls with C macros
  811.     which compile to the appropriate system call based on the
  812.     operating system.  But, if I do it this way then all the
  813.     system calls should be programmed this way.  Has anyone
  814.     thought about this problem?  I think it is almost 
  815.     impossible to do in a general way that applies to all OS.
  816.  
  817.     c) Replace the use of varargs system calls (va_alist,
  818.     va_dcl, etc) since V-system does not seem to have an
  819.     equivalent group of system calls to handle variable
  820.     argument lists.
  821.  
  822. I would appreciate any comments you have on this project.  Even
  823. if your advice is 'Give it up!'
  824.  
  825.         Hugh Bawtree
  826.         bawtree@cmpt.sfu.cdn
  827.  
  828.  
  829. From olsson@ivy.ucdavis.edu  Sat Jul 30 12:18:08 1988
  830. Received: from megaron.arizona.edu by bocklin.arizona.edu; Sat, 30 Jul 88 12:18:08 MST
  831. Received: from clover.ucdavis.edu by megaron.arizona.edu (5.59-1.5) via SMTP
  832.     id AA29729; Sat, 30 Jul 88 12:17:58 MST
  833. Received: from ivy.ucdavis.edu by clover.ucdavis.edu (5.59/4.7)
  834.     id AA28777; Sat, 30 Jul 88 12:16:48 PDT
  835. Received: by ivy.ucdavis.edu (3.2/3.14)
  836.     id AA21663; Sat, 30 Jul 88 12:15:17 PDT
  837. Date: Sat, 30 Jul 88 12:15:17 PDT
  838. From: olsson@ivy.ucdavis.edu (Ron Olsson)
  839. Message-Id: <8807301915.AA21663@ivy.ucdavis.edu>
  840. To: info-sr@arizona.edu
  841. In-Reply-To: Hugh Bawtree's message of 21 Jul 88 13:36 -0700 <4*bawtree@cmpt.sfu.cdn>
  842. Subject: SR on non-UNIX opsys
  843.  
  844.    Date: 21 Jul 88 13:36 -0700
  845.    From: Hugh Bawtree <bawtree%cmpt.sfu.cdn%ean.ubc.ca@RELAY.CS.NET>
  846.  
  847.    I just joined the info-sr group, so I am quite ignorant of the current
  848.    development of SR.  I am hoping to implement SR on the V-system
  849.    for my M Sc thesis at Simon Fraser University, Burnaby, BC, Canada.
  850.    Some of you must know my supervisor: Stella Atkins.
  851.  
  852.    Is anyone else implementing SR on non-UNIX systems?  If so, what
  853.    kind of problems are you running into?  I hope a V-system
  854.    implementation can use a large portion of the code written for
  855.    the UNIX implementation of SR but I have found the following
  856.    changes must be made:
  857.  
  858.        a) Replace the socket module in the RTS with the V-system
  859.        communication primitives.
  860.  
  861.        b) Replace the UNIX system calls scattered throughout the
  862.        code with the appropriate V system calls.  In many cases,
  863.        this by itself would not be difficult.  However, I would
  864.        like to do it in a consistent manner.  For instance, I
  865.        could replace all the UNIX system calls with C macros
  866.        which compile to the appropriate system call based on the
  867.        operating system.  But, if I do it this way then all the
  868.        system calls should be programmed this way.  Has anyone
  869.        thought about this problem?  I think it is almost 
  870.        impossible to do in a general way that applies to all OS.
  871.  
  872.        c) Replace the use of varargs system calls (va_alist,
  873.        va_dcl, etc) since V-system does not seem to have an
  874.        equivalent group of system calls to handle variable
  875.        argument lists.
  876.  
  877.    I would appreciate any comments you have on this project.  Even
  878.    if your advice is 'Give it up!'
  879.  
  880.            Hugh Bawtree
  881.            bawtree@cmpt.sfu.cdn
  882.  
  883. Since no one else (apparently) has answered, I guess I'll give it a
  884. try.  Irv Elshoff (irv@arizona.edu) redid SR's RTS using V in summer
  885. 1986.  However, he ended up abandoning that project -- seems like SR's
  886. requirements and V's functionality did not mesh well.  You might ask
  887. him for the details.  Stella might recall some of the specifics too.
  888.  
  889. From gmt  Tue Aug 16 17:20:15 1988
  890. Date: Tue, 16 Aug 88 17:20:15 MST
  891. From: "Gregg Townsend" <gmt>
  892. Message-Id: <8808170020.AA15146@megaron.arizona.edu>
  893. Received: by megaron.arizona.edu (5.59-1.6/7)
  894.     id AA15146; Tue, 16 Aug 88 17:20:15 MST
  895. To: info-sr
  896. Subject: distributed dining philosophers
  897.  
  898. Several people have pointed out that the "distributed dining philosophers"
  899. program presented in the SR Overview paper doesn't compile.  That is because
  900. it was written for a slightly older version of the language.  Here's a
  901. corrected version.
  902.  
  903.      Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  904.      +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  905.  
  906. ---------------------------- cut here -------------------------------------
  907. ##  Distributed Dining Philosophers
  908. #
  909. #   Based on the example in "An Overview of the SR Language and Implementation",
  910. #   by Greg Andrews, Ron Olsson, and a cast of thousands, in the January, 1988
  911. #   issue of TOPLAS (ACM Transactions on Programming Languages and Systems 10,1,
  912. #   51-86).
  913. #
  914. #   The algorithm is from Chandy and Misra's "Drinking Philosophers Problem",
  915. #   which appeared in the October, 1984, issue of TOPLAS (6,4, 632-646).
  916. #
  917. #   usage:  a.out n s    (for n philosophers and s sessions)
  918.  
  919.  
  920.  
  921. #   Abstract operations define two types of servant operations.
  922.  
  923. resource PhilosopherOps        # services provided to the philosopher
  924.     op getforks()  {call}
  925.     op relforks()
  926. end
  927.  
  928. resource ServantOps        # messages exchanged among servants
  929.     op needL()    {send}        # requests for a fork
  930.     op needR()    {send}
  931.     op passL()    {send}        # passing a fork to a neighbor
  932.     op passR()    {send}
  933. end
  934.  
  935.  
  936.  
  937. #   Servants do all the work.  There's one for each philosopher.
  938.  
  939. resource Servant
  940.     extend PhilosopherOps, ServantOps
  941.     op links(l,r : cap ServantOps)            # init neighbor links
  942.     op forks(haveL, dirtyL, haveR, dirtyR : bool)    # init fork values
  943.  
  944. body Servant(id : int)
  945.     var l, r : cap ServantOps
  946.     var haveL, dirtyL, haveR, dirtyR : bool
  947.     op hungry()    {send}
  948.     op eat()    {send}
  949.  
  950.     proc getforks()
  951.     write("philosopher", id, "is hungry")
  952.     send hungry()     # let server know philosopher is hungry
  953.     receive eat()     # wait for permission to eat
  954.     end
  955.  
  956.     process server
  957.     receive links(l,r)
  958.     receive forks(haveL,dirtyL,haveR,dirtyR)
  959.     write("servant",id,"is executing")
  960.         do true->
  961.         in hungry() ->
  962.         # ask for forks I do not have -- note: I ask my right
  963.         # neighbor for his left fork, and my left neighbor for
  964.         # his right fork
  965.             if ~haveR -> send r.needL() fi
  966.             if ~haveL -> send l.needR() fi
  967.         # wait until I have both forks
  968.             do ~(haveL & haveR) ->
  969.             in passL() -> haveL := true; dirtyL := false
  970.             [] passR() -> haveR := true; dirtyR := false
  971.             [] needR() & dirtyR ->
  972.                 haveR := false; dirtyR := false
  973.                 send r.passL()
  974.             [] needL() & dirtyL ->
  975.                 haveL := false; dirtyL := false
  976.                 send l.passR()
  977.             ni
  978.             od
  979.         # let my philosopher eat; wait for him to finish
  980.             send eat(); dirtyL := true; dirtyR := true
  981.             receive relforks()
  982.         [] needR() ->   
  983.         # right neighbor needs his left fork, which is my right fork
  984.             haveR := false; dirtyR := false
  985.             send r.passL()
  986.         [] needL() ->
  987.         # left neighbor needs his right fork, which is my left fork
  988.             haveL := false; dirtyL := false
  989.             send l.passR()
  990.         ni
  991.     od
  992.     end server
  993.  
  994. end Servant
  995.  
  996.  
  997.  
  998. #  The Philosopher resource is simple.
  999.  
  1000. resource Philosopher
  1001.     import PhilosopherOps
  1002.  
  1003. body Philosopher(myservant : cap PhilosopherOps; id, t : int)
  1004.     process phil
  1005.     fa i := 1 to t ->
  1006.         myservant.getforks()
  1007.         write("philosopher",id,"is eating")        # eat
  1008.         myservant.relforks()
  1009.         write("philosopher",id,"is thinking")    # think
  1010.     af
  1011.     end
  1012.  
  1013. end Philosopher
  1014.  
  1015.  
  1016.  
  1017.  
  1018. #  The main resource starts everything up.
  1019.  
  1020. resource Main
  1021.     import Philosopher, PhilosopherOps, ServantOps, Servant
  1022.  
  1023. body Main()
  1024.     initial
  1025.     var n := 5
  1026.     var t := 3
  1027.     getarg(1,n)    # get number of philosophers, if specified
  1028.     getarg(2,t)    # get session count, if specified
  1029.     
  1030.       var s[1:n]  : cap Servant
  1031.       var si[1:n] : cap ServantOps
  1032.     var pi[1:n] : cap PhilosopherOps
  1033.     var p[1:n]  : cap Philosopher
  1034.  
  1035.     # create each servant and philosopher
  1036.         fa i := 1 to n ->
  1037.         s[i] := create Servant(i)
  1038.         si[i].needL := s[i].needL        # build ServantOp cap
  1039.         si[i].needR := s[i].needR
  1040.         si[i].passL := s[i].passL
  1041.         si[i].passR := s[i].passR
  1042.         pi[i].getforks := s[i].getforks    # build PhilosopherOp cap
  1043.         pi[i].relforks := s[i].relforks
  1044.         p[i] := create Philosopher(pi[i],i,t)
  1045.       af
  1046.     # give each Servant its links to neighboring Servants
  1047.       send s[1].links(si[n],si[2])
  1048.           fa i := 2 to n-1 -> send s[i].links(si[i-1],si[i+1]) af
  1049.       send s[n].links(si[n-1],si[1])
  1050.     # initialize each Servant's forks
  1051.     #   note:  this must be asymmetric or deadlock could result
  1052.     send s[1].forks(true,false,true,false)
  1053.     fa i := 2 to n-1 ->  send s[i].forks(false,false,true,false) af
  1054.     send s[n].forks(false,false,false,false)
  1055.     end
  1056.  
  1057. end Main
  1058.  
  1059. From gmt  Wed Sep 21 17:11:52 1988
  1060. Date: Wed, 21 Sep 88 17:11:52 MST
  1061. From: "Gregg Townsend" <gmt>
  1062. Message-Id: <8809220011.AA03886@megaron.arizona.edu>
  1063. Received: by megaron.arizona.edu (5.59-1.7/12)
  1064.     id AA03886; Wed, 21 Sep 88 17:11:52 MST
  1065. To: info-sr
  1066. Subject: Code for SR on an HP 9000s800
  1067.  
  1068. We've just received a copy of the code needed to run SR under HP-UX
  1069. on a Hewlett-Packard HP9000s800 (or presumably on others of similar
  1070. architecture).
  1071.  
  1072. We hope to integrate this code into a future release of SR, but if you
  1073. can't wait...
  1074.  
  1075. I've put a copy of the code in the "sr" subdirectory of the anonymous FTP
  1076. area on Arizona.EDU (128.196.6.1 or 192.12.69.1).  It's a little big to send
  1077. to the whole mailing list, but if you need it and can't FTP I can send
  1078. individual copies.
  1079.  
  1080.     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  1081.     +1 602 621 4325      gmt@Arizona.EDU       110 57 16 W / 32 13 45 N / +758m
  1082.  
  1083. From gmt  Fri Dec 30 16:00:30 1988
  1084. Date: Fri, 30 Dec 88 16:00:30 MST
  1085. From: "Gregg Townsend" <gmt>
  1086. Message-Id: <8812302300.AA10210@megaron.arizona.edu>
  1087. Received: by megaron.arizona.edu (5.59-1.7/15)
  1088.     id AA10210; Fri, 30 Dec 88 16:00:30 MST
  1089. To: info-sr
  1090. Subject: sr-mode for GNU Emacs
  1091.  
  1092. David Jacobson of Hewlett-Packard has contributed this sr-mode package
  1093. for use with GNU Emacs:
  1094.  
  1095.  
  1096.  
  1097. ;; This is sr-mode for GNU EMACS.  It provides a mode for editing sr programs.
  1098. ;; Author: David Jacobson  (jacobson@hplabs.hp.com).
  1099. ;; 
  1100. ;; Copyright (c) 1988 Hewlett-Packard Company, all rights reserved.
  1101. ;; 
  1102. ;;                             LEGAL NOTICE
  1103. ;; 
  1104. ;; This sr-mode package is experimental and HP shall have no obligation to
  1105. ;; maintain or support it.  HP makes no express or implied warranty of any
  1106. ;; kind with respect to this software, and HP shall not be liable for any
  1107. ;; direct, indirect, special, incidental or consequential damages (whether
  1108. ;; based on contract, tort or any other legal theory) arising in any way from
  1109. ;; use of the software.
  1110. ;; 
  1111. ;; Everyone is granted permission to copy, modify and redistribute this
  1112. ;; sr-mode package, provided:
  1113. ;;  1.  All copies contain this copyright notice.
  1114. ;;  2.  All modified copies shall carry a prominant notice stating who
  1115. ;;      made the last modification and the date of such modification.
  1116. ;;  3.  No charge is made for this software or works derived from it.  
  1117. ;;      This clause shall not be construed as constraining other software
  1118. ;;      distributed on the same medium as this software, nor is a
  1119. ;;      distribution fee considered a charge.
  1120. ;;
  1121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1122. ;;      Original distribution, David Jacobson, Dec. 30, 1988
  1123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1124.  
  1125. (defconst demo-emacs-sr-bug nil
  1126.   "*Set to t to demo the match-beginning bug in emacs.")
  1127.  
  1128. (defconst sr-paren-indent 1
  1129.   "*extra indent added in sr mode for every level
  1130.    of paren nesting.")
  1131.  
  1132. (defconst sr-block-indent 3
  1133.   "*indent for inner part of most sr constructs that
  1134.    contains other statements")
  1135.  
  1136. (defconst sr-guard-indent 5
  1137.   "*indent for inner part of sr guarded commands")
  1138.  
  1139. (defconst sr-break-indent  6
  1140.   "*Extra indent to indent unfinished statements in sr mode.")
  1141.  
  1142. (defvar sr-break-symbols '("(;," "(,")
  1143.   "*If the symbols \";\", \",\", or \"(\" appear at the end of a line, the
  1144. following line is (usually) considered broken only if the symbol is a 
  1145. character in the car of sr-break-symbols.  
  1146. \\[cycle-sr-break-symbols] will cycle the list to the left.")
  1147.  
  1148. (defvar sr-neg-paren-indent nil)
  1149. (defvar sr-neg-block-indent nil)
  1150. (defvar sr-neg-guard-indent nil)
  1151.  
  1152. (defun sr-internal-setup ()
  1153.   "Called to set dependent data structures from advertized ones."
  1154.   (setq sr-neg-paren-indent (- 0 sr-paren-indent))
  1155.   (setq sr-neg-block-indent (- 0 sr-block-indent))
  1156.   (setq sr-neg-guard-indent (- 0 sr-guard-indent)))
  1157.  
  1158. (defvar sr-mode-map nil
  1159.   "Keymap used in sr mode.")
  1160.  
  1161. (defvar sr-mode-abbrev-table nil
  1162.   "Abbrev table in use in sr-mode buffers.")
  1163. (define-abbrev-table 'sr-mode-abbrev-table ())
  1164.  
  1165. (if sr-mode-map
  1166.     ()
  1167.   (setq sr-mode-map (make-sparse-keymap))
  1168.   (define-key sr-mode-map "\177" 'backward-delete-char-untabify)
  1169.   (define-key sr-mode-map "\t" 'sr-indent-line)
  1170.   (define-key sr-mode-map "\e\C-\\" 'sr-indent-region)
  1171.   (define-key sr-mode-map "\C-c\C-i" 'sr-indent-buffer)
  1172.   (define-key sr-mode-map "\C-j" 'sr-indent-newline-and-indent)
  1173.   (define-key sr-mode-map "\C-c;" 'cycle-sr-break-symbols)
  1174. )
  1175.  
  1176.  
  1177. (defvar sr-mode-syntax-table nil
  1178.   "Syntax table used in sr-mode buffers.")
  1179.  
  1180. (if sr-mode-syntax-table
  1181.     ()
  1182.   (setq sr-mode-syntax-table (make-syntax-table))
  1183.   (modify-syntax-entry ?_  "w"  sr-mode-syntax-table)
  1184.   (modify-syntax-entry ?\\ "\\" sr-mode-syntax-table)
  1185.   (modify-syntax-entry ?# "<" sr-mode-syntax-table)
  1186.   (modify-syntax-entry ?\n ">" sr-mode-syntax-table)
  1187.   (modify-syntax-entry ?+ "." sr-mode-syntax-table)
  1188.   (modify-syntax-entry ?- "." sr-mode-syntax-table)
  1189.   (modify-syntax-entry ?= "." sr-mode-syntax-table)
  1190.   (modify-syntax-entry ?* "." sr-mode-syntax-table)
  1191.   (modify-syntax-entry ?/ "." sr-mode-syntax-table)
  1192.   (modify-syntax-entry ?% "." sr-mode-syntax-table)
  1193.   (modify-syntax-entry ?< "." sr-mode-syntax-table)
  1194.   (modify-syntax-entry ?> "." sr-mode-syntax-table)
  1195.   (modify-syntax-entry ?& "." sr-mode-syntax-table)
  1196.   (modify-syntax-entry ?| "." sr-mode-syntax-table)
  1197.   (modify-syntax-entry ?\' "\"" sr-mode-syntax-table)
  1198.   (modify-syntax-entry ?\' "\'" sr-mode-syntax-table)
  1199.   ; I wish Gnu could know that " matched " and ' matched '.
  1200. )
  1201.  
  1202. (defconst sr-obarray (make-vector 127 nil)
  1203.   "A obarray for the sr symbols.
  1204. Not using the regular obarray prevents interference from anyone
  1205. else trying the same trick.")
  1206.  
  1207. (defvar sr-symbol-RE nil
  1208.   "A pattern to recognize symbols in sr.")
  1209.  
  1210. (defun setup-sr-symbols (symbol &optional beginner ender pre-indent 
  1211.                 post-indent)
  1212.   "Sets SYMBOL (as string) to have BEGINNER, ENDER, PRE-INDENT,
  1213.    and POST-INDENT properties.  See source code for big comment."
  1214.  
  1215. ; Many symbols are interned under their actual character representation,
  1216. ; even though it is not normal lisp syntax, using the intern function.
  1217. ; These symbols then have property lists to help sr-mode parse and
  1218. ; indent. If the beginner property is 'absolute, the symbol will be indented
  1219. ; with respect to the left margin instead of the previous line.  
  1220. ; If beginner is 'always.  This symbol cannot begin a statement so always 
  1221. ; add extra indent if it does.  If beginner is 'never or 'absolute, do not 
  1222. ; add extra indent.  If the ender property is 'always, a line ending in this
  1223. ; symbol cannot be the end of a statement, so always add extra indent.  If
  1224. ; the ender property is 'never, a statement ending in this symbol is always
  1225. ; complete, so never add extra indent to the next statement.  When the ender
  1226. ; is 'special, it is equivalent to 'always if the symbol is a character in
  1227. ; the car of sr-break-symbols otherwise it is equivalent to nil.
  1228. ; The pre-indent and post-indent will be evaluated when indenting is done, so 
  1229. ; 'sr-guard-indent we become the value of sr-guard-indent.  Those names
  1230. ; are so long that an abbreviation is used g=> guard, b=>block, p=>paren, 
  1231. ; these are prefixed with + or - in an obvious way.
  1232. ; Conceptually the indent algorithm keeps a running indent, adding each
  1233. ; symbol's pre-indent property, if it the first in a line, indenting to that
  1234. ; distance, then adding post-indent.
  1235.   (let ((sym (intern symbol sr-obarray))
  1236.     (tr-alist '((+b sr-block-indent)
  1237.             (-b sr-neg-block-indent)
  1238.             (+g sr-guard-indent)
  1239.             (-g sr-neg-guard-indent)
  1240.             (+p sr-paren-indent)
  1241.             (-p sr-neg-paren-indent))))
  1242.     (if beginner (put sym 'beginner beginner))
  1243.     (if ender (put sym 'ender ender))
  1244.     (if (and (> (length symbol) 1)
  1245.          (not (eq (char-syntax (string-to-char symbol))  ?w)))
  1246.     (if (null sr-symbol-RE)
  1247.         (setq sr-symbol-RE (regexp-quote symbol))
  1248.       (setq sr-symbol-RE (concat sr-symbol-RE "\\|" (regexp-quote symbol)))))
  1249.     (if post-indent (put sym 'post-indent
  1250.              (or (car (cdr (assq post-indent tr-alist))) post-indent)))
  1251.     (if pre-indent (put sym 'pre-indent
  1252.             (or (car (cdr (assq pre-indent tr-alist))) pre-indent)))))
  1253.  
  1254. (setq sr-symbol-RE nil)
  1255.  
  1256. (setup-sr-symbols "global"   'absolute 'never   0    '+b)  ; should be followed by ident
  1257. (setup-sr-symbols "end"      'never    nil      '-b  0)    ; may be followed by ident
  1258. (setup-sr-symbols "resource" 'absolute 'always  0    '+b)  ; should be followed by ident
  1259. (setup-sr-symbols "body"     'absolute 'always  0    '+b)  ; should be followed by ident
  1260. (setup-sr-symbols "proc"     'absolute 'always  '+b  '+b)  ; should be followed by ident
  1261. (setup-sr-symbols "process"  'absolute 'always  '+b  '+b)  ; should be followed by ident
  1262. (setup-sr-symbols "import"   'never    'always  0    0)    ; should be followed list
  1263. (setup-sr-symbols "extend"   'absolute 'always  '+b  0)
  1264. (setup-sr-symbols "initial"  'absolute 'never   '+b  '+b)
  1265. (setup-sr-symbols "final"    'absolute 'never   '+b  '+b)
  1266. (setup-sr-symbols "if"       'never    'always  0    '+g)  ; should be followed by expression
  1267. (setup-sr-symbols "->"       'always   'never   0    0)    ; should be followd by block, which we should not indent
  1268. (setup-sr-symbols "st"       'always   'always)
  1269. (setup-sr-symbols "[]"       'never    'always  '-g  '+g)  ; should be followed by expression
  1270. (setup-sr-symbols "else"     'always   'always)
  1271. (setup-sr-symbols "fi"       'never    'never   '-g  0)    ; always ends statement
  1272. (setup-sr-symbols "do"       'never    'always  0    '+g)  ; should be followed by expression
  1273. (setup-sr-symbols "od"       'never    'never   '-g  0)    ; always ends statement
  1274. (setup-sr-symbols "fa"       'never    'always  0    '+b)  ; should be followed by quantifiers
  1275. (setup-sr-symbols "af"       'never    'never   '-b  0)    ; always ends statement
  1276. (setup-sr-symbols "co"       'never    nil      0    '+b)  ; can be followed by interaction quantifier
  1277. (setup-sr-symbols "//"       'never    'never   '-b  '+b)
  1278. (setup-sr-symbols "oc"       'never    'never   '-b  0)    ; always ends statement
  1279. (setup-sr-symbols "in"       'never    'always  0    '+g)  ; must match []
  1280. (setup-sr-symbols "ni"       'never    'never   '-g  0)
  1281. (setup-sr-symbols "("        'always   'special 0    '+p)  
  1282. (setup-sr-symbols ")"        'always   nil      '-p  0)
  1283. (setup-sr-symbols "["        'always   'always  0    '+p)
  1284. (setup-sr-symbols "]"        'always   nil      '-p  0)
  1285. (setup-sr-symbols "{"        'always   'always  0    '+p)
  1286. (setup-sr-symbols "}"        'always   nil      '-p  0)
  1287. (setup-sr-symbols "stop"     'never    nil)           ; can be followed by expression
  1288.                               ; This can not work exactly right, since
  1289.                               ; we can not tell difference between beg. of expr. and
  1290.                               ; beg. of stmt.
  1291. (setup-sr-symbols "skip"     'never    'never)
  1292. (setup-sr-symbols "exit"     'never    'never)
  1293. (setup-sr-symbols "next"     'never    'never)
  1294. (setup-sr-symbols "++"       'always   'never)
  1295. (setup-sr-symbols "--"       'always   'never)
  1296. (setup-sr-symbols ":=:"      'always   'always) ; put before := to avoid a bug in regexp searching
  1297. (setup-sr-symbols ":="       'always   'always)
  1298. (setup-sr-symbols ">"        'always   'always)
  1299. (setup-sr-symbols ">="       'always   'always)
  1300. (setup-sr-symbols "<"        'always   'always)
  1301. (setup-sr-symbols "<="       'always   'always)
  1302. (setup-sr-symbols "="        'always   'always)
  1303. (setup-sr-symbols "!="       'always   'always)
  1304. (setup-sr-symbols "~="       'always   'always)
  1305. (setup-sr-symbols "."        'always   'always) ; may change when floats are added
  1306. (setup-sr-symbols ":"        'always   'always)
  1307. (setup-sr-symbols ";"        'always   'special)
  1308. (setup-sr-symbols "||"       'always   'always)
  1309. (setup-sr-symbols "<<"       'always   'always)
  1310. (setup-sr-symbols ">>"       'always   'always)
  1311. (setup-sr-symbols "@"        'always   'always)
  1312. (setup-sr-symbols "+"        'always   'always)
  1313. (setup-sr-symbols "-"        'always   'always)
  1314. (setup-sr-symbols "~"        'always   'always)
  1315. (setup-sr-symbols "?"        'always   'always)
  1316. (setup-sr-symbols "*"        'always   'always)
  1317. (setup-sr-symbols "/"        'always   'always)
  1318. (setup-sr-symbols "%"        'always   'always)
  1319. (setup-sr-symbols "not"      'always   'always)
  1320. (setup-sr-symbols ","        'always   'special)
  1321. (setup-sr-symbols "and"      'always   'always)
  1322. (setup-sr-symbols "&"        'always   'always)
  1323. (setup-sr-symbols "or"       'always   'always)
  1324. (setup-sr-symbols "|"        'always   'always)
  1325. (setup-sr-symbols "xor"      'always   'always)
  1326. (setup-sr-symbols "on"       'always   'always)
  1327. (setup-sr-symbols "destroy"  'never    'always)
  1328. (setup-sr-symbols "create"   'never    'always)
  1329. (setup-sr-symbols "receive"  'never    'always)
  1330. (setup-sr-symbols "send"     'never    'always)
  1331. (setup-sr-symbols "reply"    'never    'never)
  1332. (setup-sr-symbols "return"   'never    'never)
  1333. (setup-sr-symbols "ref"      'always   'always)
  1334. (setup-sr-symbols "res"      'always   'always)
  1335. (setup-sr-symbols "const"    'never    'always)       ; should be followed by ident
  1336. ;(setup-sr-symbols "bool"     nil       nil)      
  1337. ;(setup-sr-symbols "char"     nil       nil)
  1338. ;(setup-sr-symbols "int"      nil       nil)
  1339. (setup-sr-symbols "string"   nil       'always)       ; must be followed by (len)
  1340. (setup-sr-symbols "enum"     'always   'always)
  1341. (setup-sr-symbols "type"     'never    'always)       ; should be followed by ident
  1342. (setup-sr-symbols "var"      'nil      'always)          ; var is wierd, since it is both 
  1343.                                   ; used to declare variables and
  1344.                               ; as a parameter mode
  1345. (setup-sr-symbols "optype"   'never    'always)       ; should be followed by ident
  1346. (setup-sr-symbols "op"       'absolute 'always '+b  0); should be followed by ident
  1347. (setup-sr-symbols "external" 'absolute 'always '+b  0); just like op
  1348. (setup-sr-symbols "returns"  'always   'always)
  1349. (setup-sr-symbols "\"\""     'always   nil)           ; Does not appear in real sr.
  1350. (setup-sr-symbols "by"       'always   'always)
  1351. (setup-sr-symbols "call"     'never    'always)
  1352. (setup-sr-symbols "cap"      'always   'always)
  1353. (setup-sr-symbols "to"       'always   'always)
  1354. (setup-sr-symbols "downto"   'always   'always)
  1355.  
  1356. (setq sr-symbol-RE (concat sr-symbol-RE "\\|\\sw+\\|\\S "))
  1357. ;;; The single character thing must go on the end to avoid a feature
  1358. ;;; in the RE matcher that causes the first pattern appearing
  1359. ;;; *in the RE* to be matched.
  1360.  
  1361. (defconst sr-symbol-RE-bol (concat "^\\(" sr-symbol-RE "\\)")
  1362.   "An RE that matches words, sr-symbols, plus single characters when
  1363.    against the left margin.")
  1364.  
  1365. (defconst sr-symbol-RE-eol (concat "\\(" sr-symbol-RE "\\)$")
  1366.   "An RE that matches words, sr-symbols, plus single characters when
  1367.    against the right  margin.")
  1368.  
  1369.  
  1370.  
  1371. (defun sr-mode ()
  1372.   "Estabishes a mode for editing SR programs.
  1373.  
  1374. Use \\[sr-indent-line] to indent a single line.  One or two
  1375.     C-u prefixes add or subtract sr-break-indent (when appropriate).
  1376. Use \\[newline-and-indent] to go to a new line and position the
  1377.     cursor at about the right place.  (LFD is Control-J.) Prefix
  1378.     args apply as with \\[sr-indent-line]. 
  1379. Use \\[sr-indent-region] to indent region defined by point and mark.
  1380. Use \\[sr-indent-buffer] to indent entire buffer.
  1381. Use \\[cycle-sr-break-symbols] to cycle between various options
  1382. regarding the symbols that, when appearing at the end of a line,
  1383. cause the next line to be broken.  In the default configuration, 
  1384. this toggles between a terminating semicolon causing or not causing
  1385. the following line to be tucked under.
  1386.  
  1387. Variables controlling indentation style:
  1388.  
  1389. sr-block-indent controls the indentation after constructs such as 
  1390.   \"resource\", \"proc\", \"initial\", \"fa\", etc.
  1391.  
  1392. sr-guard-indent controls the indentation of commands that involve 
  1393.   guards, such as \"if\", \"do\", and \"in\".
  1394.  
  1395. sr-break-indent controls the amount by which statement 
  1396.   continuations are tucked under the beginning of the statement.
  1397.  
  1398. sr-paren-ident is an extra amount that statement continuations get 
  1399. tucked under for each level of paren nesting.
  1400.  
  1401. sr-break-symbols controls whether \";\", \",\", and \"(\" cause
  1402. the following statement to be tucked under. 
  1403.  
  1404. Change these with \\[set-variable].
  1405.  
  1406. Good possibilities for these variables and their corresponding
  1407. coding disciplines are:
  1408. 1.  (Default) sr-break-symbols = '(\"(;,\" \"(,\")).  You must use semicolons
  1409.     to separate lines of parameter specificiations and record fields.
  1410.     Avoid semicolons at ends of statements unless you change mode with
  1411.     \\[cycle-sr-break-symbols].
  1412. 2.  sr-break-symbols =  '(\"\" \",\") and sr-paren-indent = sr-break-indent.  
  1413.     Semicolons may be used in any way desired.  When not inside parentheses,
  1414.     avoid ending lines with commas.  (This affects import and extend clauses.)
  1415.     \\[cycle-sr-break-symbols] can change the mode to allow these commas.
  1416.     Sometimes produces funny results on long arithmetic expressions.
  1417.  
  1418. In all cases, no (uncommented) keywords (e.g. initial, final) after \"end\".
  1419.  
  1420. Entering sr-mode calls the value of sr-mode-hook."
  1421.  
  1422.   (interactive)
  1423.   (kill-all-local-variables)
  1424.   (use-local-map sr-mode-map)
  1425.   (setq mode-name "sr-mode")
  1426.   (setq major-mode 'sr-mode)
  1427.   (setq local-abbrev-table sr-mode-abbrev-table)
  1428.   (set-syntax-table sr-mode-syntax-table)
  1429.   (make-local-variable 'indent-line-function)
  1430.   (setq indent-line-function 'sr-indent-line)
  1431.   (make-local-variable 'indent-region-function)
  1432.   (setq  indent-region-function 'sr-indent-region)
  1433.   (make-local-variable 'comment-start)
  1434.   (setq comment-start "#")
  1435.   (run-hooks 'sr-mode-hook)
  1436. )
  1437.  
  1438.  
  1439. (defun parse-sr (&optional begin-point end-point)
  1440.   "Parses an sr program. Output a list of strings that are genuine sr
  1441.    and all appear on one line or numbers that are buffer postions of
  1442.    newline characters.  Optional first arg specifies beginning of parse,
  1443.    which defaults to first global, resource, body, or proc that begins
  1444.    a line (intervening whitespace allowed).  Optional end-point bounds the 
  1445.    end of the parse.  It defaults to point.  Don't call this."
  1446.   (save-excursion
  1447.     (let ((cdot (point))
  1448.       symstart
  1449.       symend
  1450.       symlist)
  1451.       (if (null end-point)
  1452.       (progn
  1453.         (end-of-line)
  1454.         (setq end-point (point))
  1455.         (goto-char cdot)))
  1456.       (if (null begin-point)
  1457.       (progn
  1458.         (re-search-backward
  1459.            "^\\s *\\(global\\>\\|resource\\>\\|body\\>\\|proc\\>\\)" nil 'move)
  1460.         (setq begin-point (point))))
  1461.       (goto-char begin-point)
  1462.       (if (bolp) (setq symlist (cons (point) symlist)))
  1463.       (skip-chars-forward " \t")
  1464.       (while (< (point) end-point)
  1465.     (setq symstart (point))
  1466.     (cond
  1467.      ((eq (following-char) ?\n)
  1468.           (forward-char)
  1469.           (setq symlist (cons (point) symlist)))
  1470.      ((eq (following-char) ?\")
  1471.       (if (re-search-forward "\"[^\"]*\\(\\\\.\\[^\"]*\\)*\""
  1472.                  end-point 'move)
  1473.           (progn
  1474.         (setq symend (point))
  1475.         (setq symlist (cons (buffer-substring symstart symend)
  1476.                    symlist)))))
  1477.      ((eq (following-char) ?\')
  1478.       (if (re-search-forward "\'[^\']*\\(\\\\.\\[^\']*\\)*\'"
  1479.                  end-point 'move)
  1480.           (progn
  1481.         (setq symend (point))
  1482.         (setq symlist (cons (buffer-substring symstart symend)
  1483.                    symlist)))))
  1484.      ((eq (following-char) ?#)
  1485.       (end-of-line))
  1486.      ((looking-at "/\\*")
  1487.       (skip-over-sr-comment))
  1488.      (t
  1489.       (if (re-search-forward "#\\|/\\*\\|\n\\|\"\\|\'" end-point 'move)
  1490.           (goto-char (match-beginning 0)))
  1491.       (skip-chars-backward " \t")
  1492.       (setq symend (point))
  1493.       (setq symlist (cons (buffer-substring symstart symend)
  1494.                   symlist))))  ; end of cond
  1495.     (skip-chars-forward " \t")  
  1496.     )
  1497.       symlist)))
  1498.     
  1499. (defun skip-over-sr-comment(&optional search-bound)
  1500.   "Positioned before /* moves point to just after matching */.
  1501.    An optional arg bounds the search."
  1502.   (interactive)
  1503.   (if (and (re-search-forward "/\\*" search-bound t)
  1504.        (re-search-forward "\\*/\\|\\(/\\*\\)" search-bound t))
  1505.       (let ((mb (nth 2 (match-data)))) ; work around an unfeature of 18.44.2
  1506.                        ; wherin errors occur on
  1507.                        ; (match-beginning 1) if the second
  1508.                        ; pattern did not match.
  1509.     (if mb
  1510.         (progn (goto-char mb)
  1511.            (skip-over-sr-comment)
  1512.            (re-search-forward "\\*/" search-bound t))
  1513.       t))))
  1514.            
  1515.  
  1516. (defun sr-parse-into-lines (parse-list)
  1517.   "Given a parse list such as is returned by parse-sr, returns
  1518.    an array each element of which is a list (number string),
  1519.    where number is the character in the buffer of the beginning of the line
  1520.    and string contains the line, less comments, in left to right order.  Quotes
  1521.    have been replaced by just \"\".  Don't call this."
  1522.   (let ((wkpt parse-list)
  1523.     list-of-lines
  1524.     current-line
  1525.     )
  1526.     (while wkpt
  1527.       (cond ((stringp (car wkpt))
  1528.          (setq current-line (concat
  1529.                  (if (memq (elt (car wkpt) 0) '(?\" ?\'))
  1530.                      "\"\""
  1531.                    (car wkpt))
  1532.                  current-line)))
  1533.         ((and (numberp (car wkpt)) current-line)
  1534.          (setq list-of-lines (cons (list (car wkpt) current-line) list-of-lines))
  1535.          (setq current-line nil)))
  1536.       (setq wkpt (cdr wkpt)))
  1537.     list-of-lines))
  1538.       
  1539.     
  1540. (defun sr-first-sym (string)
  1541.   "Given a string, finds the first sr symbol in it and returns it as a string"
  1542.   (and string
  1543.        (string-match sr-symbol-RE-bol string)
  1544.        (substring string 0 (match-end 1))))
  1545. ;;; Avoid the match-beginning bug by hard-coding a 0.
  1546.  
  1547. (defun sr-last-sym (string)
  1548.   "Given a string, finds the last sr symbol in it and returns it as a string"
  1549.   (and string
  1550.        (string-match sr-symbol-RE-eol string)
  1551.        (substring string (match-beginning 1) (match-end 1))))
  1552. ;;; The match-beginning bug lurks here!!!  The bug is that sometimes
  1553. ;;; (match-beginning mumble) returns the wrong value.  The appears to
  1554. ;;; happen when the match begins with the first character, in which case
  1555. ;;; (match-beginning mumble) will sometimes return 1 instead of 0.
  1556.     
  1557. (defun get-sr-indent (symbol property)
  1558.   "About like (get symbol property), except that the result is evaled, and 
  1559.    nil is converted to 0.  Intended for use in context where the symbol
  1560.    pg has the value sr-indent-guard, etc."
  1561.   (or (eval (get symbol property)) 0))
  1562.  
  1563.       
  1564. (defun sr-indent-line (&optional fudge-break arg)
  1565.   "Indents a line of sr.  A optional prefix arg adds or subtracts 
  1566.    sr-break-indent.  (One C-u adds, two subtract.)
  1567.    In a program, optional FUDGE-BREAK should be nil or numeric.
  1568.    When numeric, it adds that many 
  1569.    sr-break-indents to the indent value.
  1570.    An optional second ARG non-nill causes the previous line to be indented 
  1571.    as well.  In this case, FUDGE-BREAK applies to the previous line."
  1572.   (interactive "*P")
  1573.   (sr-internal-setup)
  1574.   (let (bdot
  1575.     parse-list
  1576.     compute-result
  1577.     indent-val
  1578.     (fudge (cond ((null fudge-break) 0)
  1579.              ((equal fudge-break '(4)) sr-break-indent)
  1580.              ((equal fudge-break '(16)) (- 0 sr-break-indent))
  1581.              ((equal fudge-break '-)    (- 0 sr-break-indent))
  1582.              (t (* sr-break-indent (prefix-numeric-value fudge-break))))))
  1583.     (save-excursion
  1584.       (forward-line 0)
  1585.       (setq bdot (point))
  1586.       (setq parse-list (nreverse (sr-parse-into-lines (parse-sr))))
  1587.       (if (null parse-list)
  1588.       ()
  1589.     ;; If the dot is in a line with program characters (blank or all
  1590.     ;; comments) the first thing in the parse-list would be the previous
  1591.     ;; line.  So we stick on a dummy line.  Yes, it is a hack.
  1592.     (if (not (eq (car (car parse-list)) bdot))
  1593.         (setq parse-list (cons (list bdot "DUMMY LINE") parse-list)))
  1594.     ;; A hack to make sr-indent-newline-and-indent work efficiently.
  1595.     ;; Clearly there must be a cleaner way to do this.
  1596.     (if arg
  1597.         (progn
  1598.           (setq compute-result (sr-compute-indent (cdr parse-list)))
  1599.           (setq indent-val (if (eq (car (cdr compute-result)) 'absolute)
  1600.                    (car compute-result)
  1601.                  (+ fudge
  1602.                     (car compute-result)
  1603.                     (save-excursion
  1604.                       (goto-char (car (nth 2 parse-list)))
  1605.                       (current-indentation)))))
  1606.           (save-excursion
  1607.         (goto-char (car (nth 1 parse-list)))
  1608.         (delete-horizontal-space)
  1609.         (indent-to indent-val)
  1610.         (forward-line 0)
  1611.         (setcar (nth 1 parse-list) (point)))))  ;; repair parse list
  1612.     (setq compute-result (sr-compute-indent parse-list))
  1613.     (setq indent-val (if (eq (car (cdr compute-result)) 'absolute)
  1614.                  (car compute-result)
  1615.                (+ (if arg 0 fudge)
  1616.                   (car compute-result)
  1617.                   (save-excursion
  1618.                 (goto-char (car (nth 1 parse-list)))
  1619.                 (current-indentation))))))
  1620.       ;; point is at the beginning of the line to be indented
  1621.       (delete-horizontal-space)
  1622.       (indent-to indent-val)) ; end of save-excursion
  1623.     (if (bolp) (skip-chars-forward " \t"))))
  1624.  
  1625. (defun sr-indent-region (beg-reg end-reg)
  1626.   "Indents a region of SR code.  Note the indentation is relative
  1627.    to the first thing in the region.  Currently there is brain damage
  1628.    when the first thing is a tail of a broken statement."
  1629.   (interactive "*rP")
  1630.   (sr-internal-setup)
  1631.   (if (interactive-p)
  1632.       (message "Indenting..."))
  1633.   (let (parse-list
  1634.     traverse-list
  1635.     wkpt
  1636.     current-line
  1637.     running-indent)
  1638.     (save-excursion
  1639.       (goto-char beg-reg)
  1640.       (forward-line 0)
  1641.       (setq beg-reg (point))
  1642.       (goto-char end-reg)
  1643.       (end-of-line)
  1644.       (setq end-reg (point))
  1645.       (setq parse-list (nreverse (sr-parse-into-lines (parse-sr beg-reg end-reg))))
  1646.       (setq wkpt parse-list)
  1647.       (while wkpt
  1648.     (sr-compute-indent wkpt)    ; do most of the work
  1649.     (setq wkpt (cdr wkpt)))
  1650.       (setq parse-list (nreverse parse-list))
  1651.       (setq wkpt parse-list)
  1652.       (while wkpt            ; traverse lines in forward direction
  1653.                     ; converting all indents to absolute
  1654.     (setq current-line (car wkpt))
  1655.     (if (eq (nth 3 current-line) 'absolute) 
  1656.         (setq running-indent (nth 2 current-line)) ; absolute indent
  1657.       (setq running-indent (+ (nth 2 current-line) ; relative indent
  1658.                   (if running-indent ; nil on first line when it is not absolute
  1659.                       running-indent
  1660.                     (goto-char (car current-line))
  1661.                     (current-indentation))))
  1662.       (setcdr (cdr current-line) (list running-indent 'absolute)))
  1663.     (setq wkpt (cdr wkpt)))        ; end of while
  1664.       (setq parse-list (nreverse parse-list))
  1665.       (setq wkpt parse-list)
  1666.       (while wkpt            ; traverse line backward
  1667.                     ; actually doing indentation
  1668.     (goto-char (car (car wkpt)))
  1669.     (delete-horizontal-space)
  1670.     (indent-to (nth 2 (car wkpt)))
  1671.     (setq wkpt (cdr wkpt)))))
  1672.     (if (interactive-p)
  1673.       (message "Indenting...done")))
  1674.  
  1675.  
  1676. (defun sr-indent-buffer ()
  1677.   "Like sr-indent-region, except does the whole buffer."
  1678.   (interactive "*")
  1679.   (if (interactive-p)
  1680.       (message "Indenting..."))
  1681.   (sr-indent-region (point-min) (point-max))
  1682.   (if (interactive-p)
  1683.       (message "Indenting...done")))
  1684.  
  1685. (defun sr-compute-indent (parse-list)
  1686.   "Given a PARSE-LIST of the form returned by sr-parse-into-lines,
  1687.    which is a list of line-lists (line-number text), each representing a line,
  1688.    sr-compute-indent appends data to the line-list at the head of
  1689.    parse-list so it has the form 
  1690.    (line-number text indent-distance relative-to), where relative-to
  1691.    is 'absolute or nil.  Nil means relative to the previous line, 
  1692.    i.e. the one represented by (cdr parse-list).  Returns a list
  1693.    (indent-distance relative-to)."
  1694.   (let*  ((lead-symbol-string (sr-first-sym (car (cdr (car parse-list)))))
  1695.       (lead-symbol  (intern-soft lead-symbol-string sr-obarray))
  1696.       (running-indent 0)
  1697.       prevline
  1698.       (sympos 0)
  1699.       current-symbol-string
  1700.       current-symbol
  1701.       match-b
  1702.       result-list)
  1703.     (cond
  1704.      ((eq (get lead-symbol 'beginner) 'absolute)
  1705.       (setq result-list (list (get-sr-indent lead-symbol 'pre-indent) 'absolute)))
  1706.      ((null (cdr parse-list))
  1707.       (setq result-list (list 0 nil)))
  1708.      (t (setq prevline (car (cdr (nth 1 parse-list))))
  1709.     ;;(message "initial indent %d" running-indent)
  1710.     ;;(sit-for 2)
  1711.     (if (sr-broken-statement (cdr parse-list))
  1712.         (setq running-indent
  1713.           (- running-indent sr-break-indent)))
  1714.     ;;(message "after broken %d" running-indent)
  1715.     ;;(sit-for 2)
  1716.     (setq running-indent
  1717.           (- running-indent
  1718.          (get-sr-indent (intern-soft (sr-first-sym prevline) sr-obarray) 'pre-indent)))
  1719.     ;;(message "deduct preindent of %s %d" (sr-first-sym prevline) running-indent)
  1720.     ;;(sit-for 2)
  1721.     (setq linelen (length prevline))
  1722.     (while (< sympos linelen)
  1723.       (setq match-b (string-match sr-symbol-RE prevline sympos))
  1724.       ;;(setq match-b (match-beginning 0))   ; bug in emacs lurks here
  1725.       (if (and demo-emacs-sr-bug
  1726.            (/= match-b (match-beginning 0)))
  1727.           (debug "match-beginning problem" match-b (match-beginning 0)))
  1728.       (setq sympos (match-end 0))
  1729.       (setq current-symbol-string
  1730.         (substring prevline match-b sympos))
  1731.       (setq current-symbol (intern-soft current-symbol-string sr-obarray))
  1732.       (setq running-indent (+ running-indent
  1733.                   (get-sr-indent  current-symbol 'pre-indent)
  1734.                   (get-sr-indent  current-symbol 'post-indent)))
  1735.       ;;(message "%s %d" current-symbol-string running-indent)
  1736.       ;;(sit-for 2)
  1737.       )  ; end of while
  1738.     (setq running-indent (+ running-indent
  1739.                 (get-sr-indent lead-symbol 'pre-indent)))
  1740.     ;;(message "%s %d" lead-symbol-string running-indent)
  1741.     ;;(sit-for 2)
  1742.     (if (sr-broken-statement parse-list)
  1743.         (setq running-indent
  1744.           (+ running-indent sr-break-indent)))
  1745.     ;;(message "add broken statement %d" running-indent)
  1746.     ;;(sit-for 2)
  1747.     (setq result-list  (list running-indent nil))))
  1748.     (setcdr (cdr (car parse-list)) result-list)))
  1749.  
  1750. (defun sr-broken-statement (parse-list)
  1751.   "Returns non-nil if the line at the head of PARSE-LIST is the continuation
  1752.    of a previous broken statement."
  1753.   (let* ((head-symbol-string (sr-first-sym (car (cdr (nth 0 parse-list)))))
  1754.      (head-symbol (and head-symbol-string
  1755.                (intern-soft head-symbol-string sr-obarray)))
  1756.      (head-beginner-prop (get head-symbol 'beginner))
  1757.      tail-symbol-string
  1758.      tail-symbol
  1759.      tail-ender-prop)
  1760.     (if head-beginner-prop
  1761.     (eq head-beginner-prop 'always)
  1762.       (setq tail-symbol-string (sr-last-sym (car (cdr (nth 1 parse-list)))))
  1763.       (setq tail-symbol (and tail-symbol-string
  1764.                  (intern-soft tail-symbol-string sr-obarray)))
  1765.       (setq tail-ender-prop (get tail-symbol 'ender))
  1766.       (cond ((eq tail-ender-prop 'always) t)
  1767.         ((eq tail-ender-prop 'special)
  1768.          (string-match tail-symbol-string (car sr-break-symbols)))
  1769.         ;;(t nil)  ; this happens automatically
  1770.         ))))
  1771.     
  1772.  
  1773. (defun sr-indent-newline-and-indent (&optional fudge-break)
  1774.   "Does what it says, but more efficiently.  An optional arg works as 
  1775.    does FUDGE-BREAK in sr-indent-line."
  1776.   (interactive "*P")
  1777.   (newline)
  1778.   (sr-indent-line fudge-break t))
  1779.  
  1780. (defun sr-cycle-break-symbols-inner (symstr sofar)
  1781.   (if (string-match symstr (car sr-break-symbols))
  1782.       sofar
  1783.     (concat sofar symstr)))
  1784.   
  1785.  
  1786. (defun cycle-sr-break-symbols ()
  1787.   "Cycles the list sr-break-symbols to the left.  Typically this is to
  1788.    toggle whether or not a trailing semicolon causes the following line
  1789.    to be tucked under."
  1790.   (interactive)
  1791.   (setq sr-break-symbols (nconc (cdr sr-break-symbols)
  1792.                 (list (car sr-break-symbols))))
  1793.   (if (interactive-p)
  1794.       (message "Breaking: \"%s\"   Non-breaking: \"%s\""
  1795.            (car sr-break-symbols)
  1796.            (sr-cycle-break-symbols-inner
  1797.         ";" (sr-cycle-break-symbols-inner
  1798.              "," (sr-cycle-break-symbols-inner
  1799.               "(" ""))))))
  1800.  
  1801.  
  1802.